<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function test(){

            var arr = [];
            for (var index = 0; index <= 10; index++) {
                
                (function(i){
                    arr[index] = function() {
                        document.write(" "+i);                
                    }
                }(index));    
            }

            return arr;
        }

        var a = test();

        for (var index = 0; index < a.length; index++) {
            a[index]();
        }



        var demo;

        function test1(){
            var abc = 100;
            function a(){
                document.write(abc);
            }
            demo = a;
        }

        test1();
        demo();




        

    </script>
</body>
</html>